-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update beamloading #906
base: master
Are you sure you want to change the base?
Update beamloading #906
Conversation
@lcarver |
Hello Laurent, |
@@ -103,7 +105,7 @@ void BeamLoadingCavityPass(double *r_in,int num_particles,int nbunch, | |||
psi = vgenk[1]; | |||
} | |||
/*Track RF cavity is always done. */ | |||
trackRFCavity(r_in,le,vgen/energy,rffreq,harmn,tlag,-psi,nturn,circumference/C0,num_particles); | |||
trackRFCavity(r_in,le,vgen/energy,rffreq,harmn,tlag,-psi+detune_angle,nturn,circumference/C0,num_particles); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you want detune_angle to have the same sign as psi?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The Vgen[1] is psi, and for a main cavity in electron machines the optimum is at -ve psi, which is -ve detuning in frequency due to the -ve gradient. It is the opposite for harmonic cavities.
I prefer to keep it as an absolute delta, which is the most logical.
@@ -154,6 +154,8 @@ def __init__(self, family_name: str, length: float, voltage: float, | |||
cavitymode (CavityMode): Is cavity ACTIVE (default) or PASSIVE | |||
buffersize (int): Size of the history buffer for vbeam, vgen, vbunch | |||
(default 0) | |||
detune_angle: Fixed detuning from optimal tuning angle. [rad] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you describe the sign convention here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to add this in the docstring of add_beamloading function as well no?
@@ -149,7 +149,7 @@ function atmexall(varargin) | |||
compile(compargs, pmeth); | |||
catch errcomp | |||
if fail | |||
rethrow(err); | |||
rethrow(errcomp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to be fixed in another PR then? Maybe you should start with this?
Added the ability to specify an additional detuning angle in the beam loading element. When considering stability issues for active cavities, it can be desirable to apply a delta detuning angle from the optimum working point.
By specifying 'detune_angle' the feedback loop will feedback on the phase position of the optimum + detune_angle.
Below is a plot comparing the PyAT results with results based on the analytical formula (taken from MB2). There is some small disagreement, but the analytical formula contains a large amount of assumptions, whereas the numerical tracking of PyAT has fewer assumptions and also takes into account the bunch distribution
I also show here a plot showing that the detune_angle is implemented correctly, as the beam remains centered on 0 as a function of the detune_angle.